{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "0e8642be-5a7d-4a21-b3aa-d47c32dc70ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 6.62607015 \\times 10^{-34}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 6.62607015 \\times 10^{-34}$"
      ],
      "text/plain": [
       "6.62607015e-34"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 1.602176634 \\times 10^{-19}\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 1.602176634 \\times 10^{-19}$"
      ],
      "text/plain": [
       "1.602176634e-19"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle 299792458.0\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle 299792458.0$"
      ],
      "text/plain": [
       "299792458.0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 物理常数调用\n",
    "from scipy import constants as const\n",
    "show(const.h)\n",
    "show(const.e)\n",
    "show(const.c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "1778a7f1-0d24-4b4f-b135-418d2c43bb85",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(6.62607015e-34, 'J Hz^-1', 0.0)"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 这里可以看更多\n",
    "const.physical_constants[\"Planck constant\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0a5a7e3d-2068-49a8-ba4e-52ed6dc50d0e",
   "metadata": {
    "jp-MarkdownHeadingCollapsed": true
   },
   "source": [
    "# 4.1 光电效应实验"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e14a4cc5-947b-4322-9906-be7c5f6aec11",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 4.1 给了些数据\n",
    "# 这玩意要数值拟合吧……有点忘了要怎么做……查一下？（好吧还是翻书）\n",
    "import numpy as np\n",
    "\n",
    "截止波长 = np.array([253.6e-9,313.2e-9,365.0e-9,404.7e-9])\n",
    "截止电压 = np.array([1.95,0.98,0.50,0.14])\n",
    "截止频率 = const.c / 截止波长"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "f6441ca5-c20e-4860-bc4a-77e634d7dcda",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\verb|[1.18214692e+15|\\verb| |\\verb|9.57191756e+14|\\verb| |\\verb|8.21349200e+14|\\verb| |\\verb|7.40777015e+14]|\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\verb|[1.18214692e+15|\\verb| |\\verb|9.57191756e+14|\\verb| |\\verb|8.21349200e+14|\\verb| |\\verb|7.40777015e+14]|$"
      ],
      "text/plain": [
       "array([1.18214692e+15, 9.57191756e+14, 8.21349200e+14, 7.40777015e+14])"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "show(截止频率)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "fee609c5-9605-4ddb-bab9-d54473765656",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html>\\(\\displaystyle \\verb|6.504582719690067e-34|\\)</html>"
      ],
      "text/latex": [
       "$\\displaystyle \\verb|6.504582719690067e-34|$"
      ],
      "text/plain": [
       "np.float64(6.504582719690067e-34)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 数据拟合……有点真不会了\n",
    "# 线性回归： https://geek-docs.com/numpy/numpy-ask-answer/572_numpy_simple_linear_regression_in_python.html\n",
    "b1, b0 = np.polyfit(截止频率.ravel(), const.e * 截止电压.ravel(), 1)\n",
    "show(b1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "231bbea9-86de-480c-9efe-2444ca751bbc",
   "metadata": {},
   "source": [
    "# 4.3 韧致辐射"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "e2de4ec7-6ebe-462e-9deb-778e5789447b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.09960496083001e-11\n",
      "3.09960496013759e-11\n",
      "4.135667696e-15\n",
      "3.09929503063453e-11\n"
     ]
    }
   ],
   "source": [
    "# 4.2\n",
    "h_ev=const.physical_constants['Planck constant in eV/Hz'][0]\n",
    "#4e4/const.h\n",
    "print(const.h * const.c /(4e4*const.e))\n",
    "print(h_ev/4e4*const.c)\n",
    "print(h_ev)\n",
    "print(h_ev/(4+4e4)*const.c)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "2641baa5-7020-41d8-a2c8-b4421984e1b7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "molar Planck constant : (3.990312712e-10, 'J Hz^-1 mol^-1', 0.0)\n",
      "molar Planck constant times c : (0.119626565582, 'J m mol^-1', 5.4e-11)\n",
      "Planck constant : (6.62607015e-34, 'J Hz^-1', 0.0)\n",
      "Planck constant in eV s : (4.135667662e-15, 'eV s', 2.5e-23)\n",
      "Planck constant over 2 pi : (1.0545718e-34, 'J s', 1.3e-42)\n",
      "Planck constant over 2 pi in eV s : (6.582119514e-16, 'eV s', 4e-24)\n",
      "Planck constant over 2 pi times c in MeV fm : (197.3269788, 'MeV fm', 1.2e-06)\n",
      "Planck length : (1.616255e-35, 'm', 1.8e-40)\n",
      "Planck mass : (2.176434e-08, 'kg', 2.4e-13)\n",
      "Planck mass energy equivalent in GeV : (1.22089e+19, 'GeV', 140000000000000.0)\n",
      "Planck temperature : (1.416784e+32, 'K', 1.6e+27)\n",
      "Planck time : (5.391247e-44, 's', 6e-49)\n",
      "Planck constant in eV/Hz : (4.135667696e-15, 'eV Hz^-1', 0.0)\n",
      "reduced Planck constant : (1.054571817e-34, 'J s', 0.0)\n",
      "reduced Planck constant in eV s : (6.582119569e-16, 'eV s', 0.0)\n",
      "reduced Planck constant times c in MeV fm : (197.3269804, 'MeV fm', 0.0)\n"
     ]
    }
   ],
   "source": [
    "for i in const.physical_constants:\n",
    "    if 'Planck' in i:\n",
    "        print(i+' : '+str(const.physical_constants[i]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "3b861189-b792-4ff4-a553-9d78afcb8adc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "\u001b[0;31mInit signature:\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m/\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
       "\u001b[0;31mDocstring:\u001b[0m     \n",
       "str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) ->\n",
       "str\n",
       "\n",
       "Create a new string object from the given object. If encoding or\n",
       "errors is specified, then the object must expose a data buffer that\n",
       "will be decoded using the given encoding and error handler. Otherwise,\n",
       "returns the result of object.__str__() (if defined) or repr(object).\n",
       "encoding defaults to sys.getdefaultencoding(). errors defaults to\n",
       "'strict'.\n",
       "\u001b[0;31mInit docstring:\u001b[0m Initialize self.  See help(type(self)) for accurate signature.\n",
       "\u001b[0;31mFile:\u001b[0m           \n",
       "\u001b[0;31mType:\u001b[0m           type\n",
       "\u001b[0;31mSubclasses:\u001b[0m     StrEnum, DeferredConfigString, FoldedCase, _rstr, _ScriptTarget, _ModuleTarget, LSString, include, Keys, InputMode, ..."
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "?str"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "161ce2e6-2db9-445c-9b8a-4e8d4878edfd",
   "metadata": {},
   "source": [
    "# 4.7 直角散射（康普顿效应）"
   ]
  },
  {
   "cell_type": "raw",
   "id": "28f4ca1e-4cba-4f24-8be2-bae89f6fec0f",
   "metadata": {},
   "source": [
    "# 书上62页 例题2可以参考"
   ]
  },
  {
   "cell_type": "raw",
   "id": "bca2733a-c88c-46ed-b640-1efd5a117ac0",
   "metadata": {},
   "source": [
    "#先抄一下书上例题2吧\n",
    "# 好吧重新把书直接看懂了（配合思维导图）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4a72a1ca-c02e-4051-96cd-b8154d2f9dba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha particle-proton mass ratio : (3.97259969009, '', 2.2e-10)\n",
      "deuteron-proton mass ratio : (1.99900750139, '', 1.1e-10)\n",
      "electron-proton mass ratio : (0.000544617021487, '', 3.3e-14)\n",
      "helion-proton mass ratio : (2.99315267167, '', 1.3e-10)\n",
      "muon-proton mass ratio : (0.1126095264, '', 2.5e-09)\n",
      "neutron-proton mass ratio : (1.00137841931, '', 4.9e-10)\n",
      "proton mass : (1.67262192369e-27, 'kg', 5.1e-37)\n",
      "proton mass energy equivalent : (1.50327761598e-10, 'J', 4.6e-20)\n",
      "proton mass energy equivalent in MeV : (938.27208816, 'MeV', 2.9e-07)\n",
      "proton mass in u : (1.007276466621, 'u', 5.3e-11)\n",
      "tau-proton mass ratio : (1.89376, '', 0.00013)\n",
      "triton-proton mass ratio : (2.99371703414, '', 1.5e-10)\n",
      "neutron-proton mass difference : (2.30557435e-30, 'kg', 8.2e-37)\n",
      "neutron-proton mass difference energy equivalent : (2.07214689e-13, 'J', 7.4e-20)\n",
      "neutron-proton mass difference energy equivalent in MeV : (1.29333236, 'MeV', 4.6e-07)\n",
      "neutron-proton mass difference in u : (0.00138844933, 'u', 4.9e-10)\n"
     ]
    }
   ],
   "source": [
    "for i in const.physical_constants:\n",
    "    if 'proton mass' in i:\n",
    "        print(i+' : '+str(const.physical_constants[i]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "d4cbbdc9-a7df-4fd0-bb6a-beace82f8676",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[λ == (6/57338586384929)]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mass = const.physical_constants['proton mass'][0]\n",
    "\n",
    "len_out , len_in, len_p = var('λ,lambda_0,lambda_e')\n",
    "len_in = const.h*const.c/(12e6 * const.e)\n",
    "len_p = const.h / (mass*const.c)\n",
    "solve(len_out-len_in == len_p*(1-cos(pi/2)),len_out)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "95dd65d9-97fa-45c9-8c5b-3e950c395050",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cos(pi/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "38bc298e-69a8-40dc-9696-6e416e356670",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.04641575216390e-13"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "6/57338586384929.n()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b9b3cb5f-d914-478a-9e60-bb0c5a548dcf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "938272088.1604904"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mass*const.c**2 / const.e"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0e2357b-f16f-479b-9749-26a42bb41560",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "raw",
   "id": "c0f59e35-3138-440c-b302-e07914573652",
   "metadata": {},
   "source": [
    "什么时候把量纲给算进来就好了……\n",
    "（查了一下好像没有？后面用英文查试试）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "4fb73c7e-dbdc-4b53-a7fc-d95518959cc8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<class 'str'>"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(const.physical_constants['proton mass'][1])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 10.5",
   "language": "sage",
   "name": "sagemath"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
